#include <fstream>
#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 2) {
        cout << "Usage: " << argv[0] << " file_name" << endl;
        return 0;
    }

    string file_name(argv[1]);
    fstream fs;
    fs.open(file_name.c_str(), fstream::in);
    if (!fs.is_open()) {
        cout << "Open file " << file_name << " error!" << endl;
        return 1;
    }
    string str;
    vector<int> vec_num;
    while (fs >> str) {
        if (str.empty()) {
            break;
        }

        int elem = atoi(str.c_str());
        vec_num.push_back(elem);
    }

    size_t elem_num = vec_num.size();
    int *array = new int[elem_num];
    if (array == NULL) {
        cout << "Allocate array buffer error!" << endl;
        return 1;
    }

    size_t i;
    for (i = 0; i < elem_num; i++) {
        array[i] = vec_num[i];
    }

    calcAllSubsets(array, elem_num);

    return 0;
}


